//# sourceURL=http://uMapApp/Module/PQI/LevelChart
define([
    "mhjs/mhjs", "mhjs/TypeExtend/String"
], function (
    mhjs, String
) {

    function LevelChart(option) {

        var _this = this;

        _this.levelClass = {
            "优" : "level1",
            "良" : "level2",
            "中" : "level3",
            "差" : "level4",
            "次" : "level5"
        };

        _this.ui = {
            paramLevel : new mhjs.Div({"class" : "level"}),
            paramValue : new mhjs.Div({"class" : "value"}),
            paramLabel : new mhjs.Div({"class" : "label"}),
            arrow      : new mhjs.Div({"class" : "arrow"})
        };

        mhjs.Div.call(_this, option);
        _this.addClass("levelChart");

        _this
            .append(_this.ui.paramLevel)
            .append(_this.ui.paramValue)
            .append(_this.ui.paramLabel)
            .append(_this.ui.arrow)
        ;

    }

    var _class = LevelChart;
    mhjs.Inherit(_class, mhjs.Div);


    Object.defineProperties(_class.prototype, {
        "param" : {
            get : function () {
                return this._param;
            },
            set : function (param) {
                var _this = this;
                _this._param = param;

                if (param.label) {
                    _this.ui.paramLabel.text(param.label);
                }

                if (param.value) {
                    _this.ui.paramValue.text(param.value.toFixed(2));
                }

                if (param.level) {
                    _this.ui.paramLevel.text(param.level);
                    _this.addClass(_this.levelClass[param.level]);
                }

            }
        }
    });

    return _class;

});